package day2;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-12-08
 * Time: 15:29
 */

//排序子序列
//https://www.nowcoder.com/questionTerminal/2d3f6ddd82da445d804c95db22dcc471?orderByHotValue=1&page=1&onlyReference=false

public class SortSubsequences {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] array = new int[n+1];

        for (int i = 0; i < n; i++) {
            //读取数据到数组当中
            array[i] = scanner.nextInt();
        }

        //遍历数组 找到子序列
        int i = 0;
        int count = 0;
        while(i<n){
            if (array[i] < array[i+1]){
                while (i<n && array[i] < array[i+1]){
                    i++;
                }
                count++;
                i++;
            } else if (array[i] == array[i+1]) {
                i++;
            }else {
                while (i<n && array[i] > array[i+1]){
                    i++;
                }
                count++;
                i++;
            }
        }
        System.out.println(count);
    }
}
